<template>
  <el-dropdown @command="langChange">
    <span>
      <svg-icon
        iconClass="language"
        style="margin-right:20px;width:25px;height:25px;color:#fff;"
      ></svg-icon>
    </span>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item command="zh">中文</el-dropdown-item>
        <el-dropdown-item command="en">English</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>
<script>
import jsCookie from 'js-cookie'
export default {
  name: 'lang',
  methods: {
    langChange (str) {
      window.console.log(str)
      this.$i18n.locale = str
      jsCookie.set('lang', str)
      // 刷新当前页
      // 刷新数据但不刷新网页
      // this.reload()
      this.$router.go(0)
    }
  }
}
</script>
<style></style>
